angular.module('faApp')
  .service('adService', [ 'ajaxService',function (ajaxService) {

    this.adList = function (cfg) {
      return ajaxService.jsonp(ajaxService.getApiUri("AD_LIST"),cfg || {});
    };  

    this.adRecommendList = function (cfg) {
      return ajaxService.jsonp(ajaxService.getApiUri("AD_RECOMMEND_LIST"),cfg || {});
    };  
    
    this.adAdd = function (ad) {
      return ajaxService.post(ajaxService.getApiUri("AD_ADD"),ad || {});
    };     

    this.adEdit = function (ad) {
      return ajaxService.post(ajaxService.getApiUri("AD_EDIT"),ad || {});
    };  

    this.adQuery = function (id) {
      return ajaxService.jsonp(ajaxService.getApiUri("AD_QUERY"),{advertId:id});
    };  

    this.adStart = function (cfg) {
      return ajaxService.jsonp(ajaxService.getApiUri("AD_EDIT"),cfg || {});
    };  

    this.adStop = function (cfg) {
      return ajaxService.jsonp(ajaxService.getApiUri("AD_EDIT"),cfg || {});
    };  

    this.msgList = function (cfg) {
      return ajaxService.post(ajaxService.getApiUri("MSG_LIST"), cfg || {});
    };

    this.msgDetail = function (id) {
      return ajaxService.post(ajaxService.getApiUri("MSG_DETAIL"), {id : id});
    };

    this.msgDelete = function (id) {
      return ajaxService.post(ajaxService.getApiUri("MSG_DELETE"), {id : id});
    };

    this.msgAdd = function (msg) {
      return ajaxService.post(ajaxService.getApiUri("MSG_ADD"), msg || {});
    };

    this.msgUpdate = function (msg) {
      return ajaxService.post(ajaxService.getApiUri("MSG_UPDATE"), msg || {});
    };

    this.actList = function (cfg) {
      return ajaxService.post(ajaxService.getApiUri("ACT_LIST"), cfg || {});
    };
    this.actPerList = function (cfg) {
      return ajaxService.jsonp(ajaxService.getApiUri("ACT_PER_LIST"), cfg || {});
    };
    this.actDetail = function (id) {
      return ajaxService.jsonp(ajaxService.getApiUri("ACT_DETAIL"), {id : id});
    };

    this.actAdd = function (act) {
      return ajaxService.post(ajaxService.getApiUri("ACT_ADD"), act || {});
    };

    this.actUpdate = function (act) {
      return ajaxService.post(ajaxService.getApiUri("ACT_UPDATE"), act || {});
    };
}]);